﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;

namespace QLBenhVien
{
    public partial class frmThanhToanTienThuoc : Form
    {
        public frmThanhToanTienThuoc()
        {
            InitializeComponent();
        }

        private void frmThanhToanTienThuoc_Load(object sender, EventArgs e)
        {
            
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            
                DataTable dt = DAODonThuoc.SearchByTen(txtFullname.Text.Trim());
                dgTienThuoc.DataSource = dt;
                dgTienThuoc.Columns["id"].Visible = false;
                dgTienThuoc.Columns["benhnhan_id"].Visible = false;
                dgTienThuoc.Columns["bacsi_id"].Visible = false;
                dgTienThuoc.Columns["ghichu"].Visible = false;
                dgTienThuoc.Columns["id1"].Visible = false;
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (dgTienThuoc.SelectedRows.Count > 0)
            {
                DataSet ds = new DataSet();
                int id = int.Parse(dgTienThuoc.CurrentRow.Cells["id"].Value.ToString());
                ds.Tables.Add(DAOHoaDon.SearchByID(id));

                ReportDocument rpt = new ReportDocument();
                rpt.Load("C:\\Documents and Settings\\Hung\\Desktop\\QLBenhVien\\QLBenhVien\\rptThanhToanTienThuoc.rpt");
                rpt.SetDataSource(ds);
                //rpt.SetParameterValue("@id",dgTienThuoc.CurrentRow.Cells["id"]);
                crystalReportViewer1.ReportSource = rpt;
            }
        }
    }
}
